package com.myblog.mapper;

import com.myblog.pojo.UserMessage;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface Usermessagemapper {
    @Select("SELECT * FROM user_message ORDER BY user_message.id DESC")
    @Results(
            value = {
                    @Result(property = "id",column = "id"),
                    @Result(property = "pOpenId",column = "p_openId"),
                    @Result(property = "content",column = "content"),
                    @Result(property = "pwechat",column = "p_openId",one = @One(select = "com.myblog.mapper.Wechatmapper.findwechat",fetchType = FetchType.DEFAULT)),
            }
    )
    public List<UserMessage> find();

    @Insert("INSERT into user_message(user_message.p_openId,user_message.content,user_message.time) VALUES(#{openId},#{content},#{time})")
    public void insert(@Param("openId") String openId,@Param("content") String content,@Param("time") String time);
}
